package com.blog.blog.service;

import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;

/**
 * TODO
 *
 * @author sean
 * @date 2020/3/28 2:50 PM
 */
public class BaseService {

    /**
     * 初始化分页
     * @param pageNum
     * @param size
     * @param sortColums
     * @return
     */
    public Pageable initPageable(int pageNum, int size, String[] sortColums) {
        Sort sort = Sort.by(Sort.Direction.DESC, sortColums);
        return PageRequest.of(pageNum-1, size,sort);
    }
}
